# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     views
   Description :   RedReins
   Author :       RedReins
   date：          2021/6/1
-------------------------------------------------
"""
# 导入蓝图 .当前路径  admin/views.py
from . import admin
# 导入flask框架中的功能
from flask import render_template, request
# from app.admin.forms import
from app.models import recentupdate,info,top30
# db是在app/__init__.py文件中设置的对象
from app import db
#导入forms.py
from app.admin.forms import  SearchForm


@admin.route("/",methods=['GET'])
def index():
    return render_template("index.html")

'''最近更新'''
@admin.route("/recentupdate",methods=['GET'])
def recent():
    data = recentupdate.query.order_by(db.asc(recentupdate.num) ).all()
    return render_template("100new.html",u=data)

'''移动端'''
@admin.route("/tv",methods=['GET'])
def Mobile():
    return render_template("Mobile.html")


@admin.route("/onePage/<title>",methods=['GET'])
def onePage(title):
    data = info.query.filter(info.title.like('%{title}%'.format(title=title))).first()
    return render_template("info.html",u=data)

'''播放'''
@admin.route("/play",methods=['GET','POST'])
def play():
    print("进入播放视图")
    return render_template('twoPage.html')

'''剧情频道'''
@admin.route("/list/<int:page>",methods=['GET','POST'])
def Channel(page):

    return render_template('list%s.html'%page)

'''2021新剧'''
@admin.route("/jijiangkaibo",methods=['GET','POST'])
def jijiang():
    return render_template('jijiangkaibo.html')
@admin.route("/xudingquxiao",methods=['GET','POST'])
def xuding():
    return render_template('xudingquxiao.html')
@admin.route("/2021meijutop",methods=['GET','POST'])
def meiju():
    return render_template('2021meijutop.html')
@admin.route("/allstate",methods=['GET','POST'])
def alstate():
    return render_template('allstate.html')

'''排行榜'''
@admin.route("/alltop_hit",methods=['GET'])
def rank():
    mohuan = top30.query.filter_by(classification='魔幻/科幻').order_by(db.asc(top30.id)).all()
    lingyi = top30.query.filter_by(classification='灵异/惊悚').order_by(db.asc(top30.id)).all()
    dushu = top30.query.filter_by(classification='都市/情感').order_by(db.asc(top30.id)).all()
    fanzhui = top30.query.filter_by(classification='犯罪/历史').order_by(db.asc(top30.id)).all()
    xuanxiu = top30.query.filter_by(classification='选秀/综艺').order_by(db.asc(top30.id)).all()
    katong = top30.query.filter_by(classification='动漫/卡通').order_by(db.asc(top30.id)).all()
    return render_template("alltop_hit.html",mohuan=mohuan,lingyi=lingyi,d=dushu,f=fanzhui,x=xuanxiu,k=katong)


'''档期表'''
@admin.route("/calendar",methods=['GET'])
def Calendar():
    return render_template("Schedule.html")

'''留言'''
@admin.route("/message",methods=['GET'])
def Message():
    return render_template("Message Board.html")



'''搜索'''
@admin.route("/searchword",methods=['post'])
def searchKey():
    title = request.form.get("searchword")
    data = info.query.filter(info.title.like('%{title}%'.format(title=title))).first()
    return render_template("info.html", u=data)







